package ui
{
	import dev.touchswipe.shared.Fonts;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	import ui.icons.TileIcons;
	import ui.icons.fileIcon;
	import ui.icons.folderIcon;
	
	public class Tile extends Sprite
	{
		public static const TILE_WIDTH:Number=120;
		public static const TILE_HEIGHT:Number=150;
		public static const TILE_BG_COLOUR:uint=0x444444;
		public static const TILE_TEXTBG_COLOUR:uint=0x33CCFF;
		public static const ICON_SIZE:uint=75;
		
		public function Tile(i:Number,j:Number,k:Number,value:String,icon:DisplayObject)
		{
			graphics.beginFill(TILE_BG_COLOUR,0.95);
			graphics.drawRoundRectComplex(-TILE_WIDTH/2,-TILE_HEIGHT/2,TILE_WIDTH,TILE_HEIGHT-30,15,15,0,0);
			graphics.beginFill(TILE_TEXTBG_COLOUR);
			graphics.drawRoundRectComplex(-TILE_WIDTH/2,TILE_HEIGHT/2-30,TILE_WIDTH,30,0,0,15,15);
			this.i=i;
			this.j=j;
			this.k=k;
			this.layer=k;
			this.value=value;
			var text:TextField=new TextField();
			var txtFmt:TextFormat=new TextFormat(Fonts.KozukaGothicProEL,14,0x000000);
			txtFmt.align=TextFormatAlign.CENTER;
			text.defaultTextFormat=txtFmt;
			text.embedFonts=true;
			text.text=(value.length>13)?value.substr(0,12)+"...":value;
			text.width=TILE_WIDTH-20;
			text.height=40;
			text.x=-(TILE_WIDTH-20)/2;
			text.y=(TILE_HEIGHT-50)/2;
			text.selectable=false;
			addChild(text);
			addChild(icon);
			var iconScale:Number=Math.max(icon.width,icon.height)/ICON_SIZE;
			icon.width/=iconScale;
			icon.height/=iconScale;
			icon.x=-icon.width/2;
			icon.y=-(20+icon.height/2);
		}
		public var i:Number;
		public var j:Number;
		public var k:Number;
		public var layer:int;
		public var value:String;
	}
}